//
//  UploadItem.m
//  iFlickr
//
//  Created by 张 霄鹤 on 09-5-17.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "UploadItem.h"


@implementation UploadItem

@synthesize title;
@synthesize description;
@synthesize isPublic;
@synthesize isFriend;
@synthesize isFamily;
@synthesize tags;
@synthesize uploadState;
@synthesize image;
@synthesize photoid;

-(id)init{
	if(self = [super init]){
		self.title = @"Image n";
		self.description = @"An Image";
		self.tags = @"tags";
		self.isPublic = YES;
		self.isFriend = NO;
		self.isFamily = NO;
		self.uploadState = US_NEEDUPLOAD;
	}
	return self;
}


/**
 * 获取图像的原始数据，目前使用 PNG 格式
 */
-(NSData *)getImageData{
	if(self.image){
		NSData *ret = UIImagePNGRepresentation(self.image);
		return [ret autorelease];
	}
	return nil;
}

-(NSDictionary *)getItemInfo{
	NSMutableDictionary *ret = [[NSMutableDictionary alloc] init];
	
	[ret setObject:title forKey:@"title"];
	
	if(description != nil){
		[ret setObject:description forKey:@"description"];
	}
	
	if(tags != nil){
		[ret setObject:tags forKey:@"tags"];
	}
	
	if(isPublic){
		[ret setObject:@"1" forKey:@"is_public"];
	}else {
		[ret setObject:@"0" forKey:@"is_public"];
	}
	
	if(isFriend){
		[ret setObject:@"1" forKey:@"is_friend"];
	}else {
		[ret setObject:@"0" forKey:@"is_friend"];
	}
	
	if(isFamily){
		[ret setObject:@"1" forKey:@"is_family"];
	}else {
		[ret setObject:@"0" forKey:@"is_family"];
	}	
	
	return [ret autorelease];
}

/**
 * 有多少项可以修改，用于 UITableView中显示 Cell个数
 */
-(NSInteger)numberOfCanModify{
	return 6;
}

/**
 * 获取相应项目的标题，名称
 */
-(NSString *)getCellTitle:(NSInteger)index{
	NSString *ret = nil;
	switch (index) {
		case 0:
			ret = @"title";
			break;
		case 1:
			ret = @"description";
			break;
		case 2:
			ret = @"tags";
			break;
		case 3:
			ret = @"isPublic";
			break;
		case 4:
			ret = @"isFriend";
			break;
		case 5:
			ret = @"isFamily";
			break;
		default:
			break;
	}
	return ret;
}

@end
